<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
		<style type="text/css">
			.content {
				width: 80%;
				height: 350px;
				overflow-y: scroll;
				padding: 0 10px;
			}

			/*滚动条样式*/
			.content::-webkit-scrollbar {
				width: 4px;
				/*height: 4px;*/
			}

			.content::-webkit-scrollbar-thumb {
				border-radius: 10px;
				-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
				background: rgba(0, 0, 0, 0.2);
			}

			.content::-webkit-scrollbar-track {
				-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
				border-radius: 0;
				background: rgba(0, 0, 0, 0.1);

			}

			h3,
			.h3 {
				font-size: 12px;
				margin: 5px 0px;
				font-weight: 400;
			}

			.layui-timeline-item {
				position: relative;
				padding-bottom: 10px;
			}

			.layui-timeline-title {
				position: relative;
				margin-bottom: 0px;
			}

			.layui-text {
				line-height: 22px;
				font-size: 9px;
				color: #666;
			}

			.layui-text-notes {
				line-height: 22px;
				font-size: 15px;
				color: #f00;
			}

			.layui-badge.layui-bg-green span {
				color: #FFF !important;
			}

			.quantity {
				display: flex;
			}

			.user_quantity {
				flex: 4;
				text-align: center;
				border: 1px solid #e6e6e6;
			}
		</style>
	</head>
	<body>

		<div class="layui-fluid reporting_style">
			<div class="layui-row" id="views">
				<!--<button type="button" class="layui-btn layui-btn-normal layui-btn-sm return">
					<i class="layui-icon layui-icon-return"></i>返回列表
				</button>-->
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
					<legend>订单详情</legend>
				</fieldset>
				<div class="layui-card">
					<div class="layui-card-body">
						<ul class="layui-timeline" id="layui-timeline">
						</ul>
						<div class="layui-row layui-col-space15" id="detail_view"></div>
						<div class="layui-row" id="view"></div>
						<div class="layui-fluid">
							<div class="layui-row" id="view">
								<h3>商品信息</h3>
								<table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate">
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<script type="text/html" id="zizeng">
		{{d.LAY_TABLE_INDEX+1}}
		</script>
		<script type="text/html" id="time_line">
		{{# layui.each(d,function(index,obj){ }}
			<li class="layui-timeline-item">
				<i class="layui-icon layui-timeline-axis"></i>
				<div class="layui-timeline-content layui-text">
					<h3 class="layui-timeline-title">
						{{ obj.addtime ? obj.addtime : '--' }}
						{{ String(obj.status) ? '<span class="layui-badge layui-bg-green">' + order_status_show(1,String(obj.status)) + '</span>' : '--' }}
					</h3>
					<p class="layui-text-notes">
						{{ obj.notes ? obj.notes : '' }}
					</p>
				</div>
			</li>
			{{# }) }}
		</script>
		<script type="text/html" id="demo">
			<div class="layui-card">
				<!--<button type="button" class="layui-btn layui-btn-normal layui-btn-sm return">
					<i class="layui-icon layui-icon-return"></i>返回列表
				</button>-->
				<div class="layui-card-body">
					<div class="layui-row details">
						<div class="layui-col-xs3">
							订单状态：<span> {{ String(d.data.status) ? order_status_show(1,d.data.status) : '' }}<span>
						</div>
						<div class="layui-col-xs3">
							订单编号：<span> {{ d.data.orderid ? d.data.orderid : '' }}<span>
						</div>
						<div class="layui-col-xs3">
							会员编号：<span> {{ d.data.memberid ? d.data.memberid : '' }}<span>
						</div>


						<div class="layui-col-xs3">
							购买数量： <span> {{ d.data.quantity ? d.data.quantity : '' }}<span>
						</div>
						<div class="layui-col-xs3">
							订单金额： <span> {{ d.data.amount ? d.data.amount : '' }}<span>
						</div>
						<div class="layui-col-xs3">
							使用红包： <span> {{ d.data.fee_packet ? d.data.fee_packet : '' }}<span>
						</div>
						<div class="layui-col-xs3">
							使用积分： <span> {{ d.data.fee_score ? d.data.fee_score : '' }}<span>
						</div>
						<div class="layui-col-xs3">
							专属折扣： <span> {{ d.data.discount?d.data.discount:'' }}<span>
						</div>
						<div class="layui-col-xs3">
							付款金额： <span> {{d.data.pay_price?d.data.pay_price:''}}<span>
						</div>
						<div class="layui-col-xs3">
							付款方式：{{d.data.payment ? '<span class="text_red_color">' + payment_show(1, d.data.payment) + '</span>' : '未付款'}}
						</div>

						<div class="layui-col-xs3">
							下单时间： <span> {{ d.data.addtime ? d.data.addtime : ''}}<span>
						</div>
						<div class="layui-col-xs3">
							付款时间： <span> {{ d.data.pay_time ? d.data.pay_time : ''}}<span>
						</div>

					</div>
				</div>
			</div>
			<div class="layui-card">
				<div class="layui-card-body">
					<!-- 核销信息 -->
					<div style="font-size:12px">核销信息</div>
					<table border="1" cellspacing="0" width="800px">
						<tr>
							<th>总数量</th>
							<th>核销时间</th>
							<th>核销数量</th>
							<th>剩余数量</th>
						</tr>
						<tr>
							<th>{{d.data.quantity?d.data.quantity:0}}</th>
							<th>{{d.data.pay_time?d.data.pay_time:0}}</th>
							<th>{{d.data.used_quantity?d.data.used_quantity:0}}</th>
							<th>{{d.data.quantity-d.data.used_quantity}}</th>
						</tr>
					</table>






					<!-- 核销信息结束 -->
					<!-- 					<div class="layui-row details">
						<div class="layui-col-xs12">
							收货人姓名：<span>{{ d.data.consignee ? d.data.consignee : '' }}<span>
						</div>
						<div class="layui-col-xs12">
							收货人电话：<span>{{ d.data.mobile ? d.data.mobile : '' }}<span>
						</div>
						<div class="layui-col-xs12">
							收货地址：<span>{{ d.data.areaname ? d.data.areaname : '' }}{{ d.data.address ? d.data.address : '' }}<span>
						</div>

						<button type="button" data-method="address" class="layui-btn layui-btn-normal audit_btn"
							id="address">修改收货</button>

						{{# if(d.data.delivery_name){ }}
							<div class="layui-col-xs12">
								快递公司：<span>{{ d.data.delivery_name ? d.data.delivery_name : '' }}<span>
							</div>
							{{# }  }}
								{{# if(d.data.delivery_waybill){ }}
									<div class="layui-col-xs12">
										快递单号：<span>{{ d.data.delivery_waybill ? d.data.delivery_waybill : '' }}<span>
												<button type="button" class="layui-btn layui-btn-xs" lay-event="orderdetail"
													id="ordersdetails">查看物流信息</button>
									</div>
									{{# }  }}
					</div> -->
				</div>
			</div>
		</script>

		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			// 核销信息

			var _data = {
				id: getParam('id'),
				orderid: getParam('orderid'),
				no: '',
				com: ''
			}
			$(function() {
				var list = []
				$.get(server.queryordersdetail, _data, function(res) {
					$.get(server.checkoffinformation, {
						orderid: res.orders_detail.data.orderid
					}, function(res) {
						list = res.orders_used.data
						$(list).each(function(i, ele) {
							console.log(i, ele)
							var tr = $('<tr>' + ele.skuname + ' </tr');
							$('#list').append(tr)
						})
					})
				})
			})



			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'table'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					table = layui.table,
					form = layui.form;

				initdata();

				function initdata() {
					var orders_sub = []
					$.get(server.queryordersdetail, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var data = res.orders_detail
								_data.com = data.data.delivery_no
								_data.no = data.data.delivery_waybill

								orders_sub = res.orders_sub
								console.log(orders_sub.data)
								var getTpl = demo.innerHTML,
									view = document.getElementById('view');
								laytpl(getTpl).render(data, function(html) {
									view.innerHTML = html;
								});
								//时间线
								var timeline = time_line.innerHTML,
									view = document.getElementById('layui-timeline')
								laytpl(timeline).render(res.orders_oplog.data, function(html) {
									view.innerHTML = html;
								});
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}

				initdata_list()

				function initdata_list() {
					table.render({
						elem: '#test-table-operate',
						url: server.queryorders_sub,
						cols: [
							[{
									width: 50,
									field: 'zizeng',
									title: '#',
									fixed: 'left',
									templet: '#zizeng'
								}, {
									field: 'orderid',
									width: 120,
									title: '订单编号'
								}, {
									field: 'memberid',
									width: 120,
									title: '会员编号'
								}, {
									field: 'userid',
									width: 120,
									title: '用户编号',
									sort: true
								}, {
									field: 'skuid',
									width: 120,
									title: '商品编号',
									sort: true
								}, {
									field: 'skuname',
									width: 160,
									title: '商品名称'
								},
								//							{
								//								field: 'spec',
								//								width: 160,
								//								title: '商品规格',
								//								toolbar:"#test-table-operate-goods"
								//							}, 
								{
									field: 'specname',
									width: 120,
									title: '规格名称',
									sort: true,
								}, {
									field: 'specparam',
									width: 120,
									title: '规格参数',
									sort: true,
								}, {
									field: 'price_member',
									width: 120,
									title: '会员价格',
								}, {
									field: 'current_price',
									width: 120,
									title: '购买价格',
								},
								/*{
																field: 'score_scale',
																width: 120,
																title: '积分可抵扣',
																templet:function(d){
																	return d.score_scale?d.score_scale+ '%':''
																}
															},*/
								{
									field: 'score',
									width: 120,
									title: '积分可抵扣'
								}, {
									field: 'quantity',
									width: 160,
									title: '商品数量'
								}, {
									field: 'amount_price',
									width: 160,
									title: '商品总价'
								}, {
									field: 'price_waybill',
									width: 120,
									title: '订单运费',
								}, {
									field: 'mobile',
									width: 120,
									title: '手机号',
								}, {
									field: 'add_by',
									width: 120,
									title: '创建人',
								}, {
									field: 'addtime',
									width: 160,
									title: '创建时间',
								}, {
									field: 'edit_by',
									width: 120,
									title: '更新人',
								}, {
									field: 'edittime',
									width: 160,
									title: '更新时间',
								}
							]
						],
						where: _data,
						request: {
							pageName: 'page',
							limitName: 'size' //每页数据量的参数名，默认：limit
						},
						parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
							return {
								"code": res.code, //解析接口状态
								"msg": res.msg, //解析提示文本
								"count": res.orders_sub.pager.total, //解析数据长度
								"data": res.orders_sub.data //解析数据列表
							};
						}
					});
				}

				$(document).on('click', '#demo2_back', function() {
					history.go(-1)
				})


				$(document).on('click', '#ordersdetails', function() {

					layer.open({
						type: 2,
						title: '物流信息',
						shadeClose: false,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['80%', '70%'],
						content: './order_details_delivery.html?com=' + _data.com + '&no=' +
							_data.no,
						end: function() {

						}
					});

				})





				//给服务修改按钮添加事件
				var active = {
					notice: function(orderid) { //修改服务状态
						console.log(orderid)
						layer.open({
							type: 2,
							title: '修改订单状态',
							shadeClose: false,
							shade: 0.5,
							area: ['40%', '60%'],
							content: 'order_status_edit.html?orderid=' + orderid,
							end: function() {
								location.reload()
							}
						});
					},
					address: function() { //修改收获地址
						layer.open({
							type: 2,
							title: '修改收货信息',
							shadeClose: false,
							shade: 0.5,
							area: ['50%', '80%'],
							content: 'edit_add_address.html?orderid=' + _data.orderid,
							end: function() {
								location.reload()
							}
						});
					},
				};

				$(document).on('click', '.audit_btn', function() {
					var othis = $(this),
						method = othis.data('method');
					active[method] ? active[method].call(this, othis.attr("value")) : '';

				});

			});

			//给类样式 .return 添加的回退功能
			$('.return').on('click', function() {
				window.history.back(-1);
			})
		</script>
	</body>
</html>
